﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mbr.Reviews.Core.Contracts;
using Mbr.Reviews.Core.ProductCrawlers;
using Mbr.Reviews.Core.ProductStores;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Mbr.Reviews.Core.Tests
{
    [TestClass]
    public class WhenProductCrawlingIsPerformed
    {
        string[] keywordsThatWillFindProducts = new string[]{ "HTC", "Phone", "8X" };
        string[] keywordsThatWillFindNoting = new string[] { "hbdkjfhalskdfh8923174kjsadhfklasdf" };

        [TestMethod]
        public void CrawlerShouldNotChangeStoreIfNothingIsFound()
        {
            IStoreProducts store = new InMemoryProductStore();
            ICrawlForProducts crawler = new InMemoryProductCrawler(store);
            crawler.BeginCrawl(keywordsThatWillFindNoting);
            Assert.IsFalse(store.Find(keywordsThatWillFindProducts).Any());
        }

        [TestMethod]
        public void CrawlerShouldStoreAnyProductItFinds()
        {
            IStoreProducts store = new InMemoryProductStore();
            ICrawlForProducts crawler = new InMemoryProductCrawler(store);
            crawler.BeginCrawl(keywordsThatWillFindProducts);
            Assert.IsTrue(store.Find(keywordsThatWillFindProducts).Any());
        }
    }
}
